home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / serverlib / trans / allocTrans.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  4.1 KB  |  142 lines

  1. /*
  2.  *   $RCSfile: allocTrans.c,v $  
  3.  *   $Revision: 1.1.1.1 $  
  4.  *   $Date: 1996/05/04 21:56:02 $      
  5.  */ 
  6. /**********************************************************************
  7. * EXODUS Database Toolkit Software
  8. * Copyright (c) 1991 Computer Sciences Department, University of
  9. *                    Wisconsin -- Madison
  10. * All Rights Reserved.
  11. *
  12. * Permission to use, copy, modify and distribute this software and its
  13. * documentation is hereby granted, provided that both the copyright
  14. * notice and this permission notice appear in all copies of the
  15. * software, derivative works or modified versions, and any portions
  16. * thereof, and that both notices appear in supporting documentation.
  17. *
  18. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  19. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  20. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  21. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  22. *
  23. * The EXODUS Project Group requests users of this software to return 
  24. * any improvements or extensions that they make to:
  25. *
  26. *   EXODUS Project Group 
  27. *     c/o David J. DeWitt and Michael J. Carey
  28. *   Computer Sciences Department
  29. *   University of Wisconsin -- Madison
  30. *   Madison, WI 53706
  31. *
  32. *     or exodus@cs.wisc.edu
  33. *
  34. * In addition, the EXODUS Project Group requests that users grant the 
  35. * Computer Sciences Department rights to redistribute these changes.
  36. **********************************************************************/
  37.  
  38. #include "sysdefs.h"
  39. #include "ess.h"
  40. #include "checking.h"
  41. #include "trace.h"
  42. #include "error.h"
  43. #include "list.h"
  44. #include "pool.h"
  45. #include "tid.h"
  46. #include "io.h"
  47. #include "lock.h"
  48. #include "object.h"
  49. #include "msgdefs.h"
  50. #include "thread.h"
  51. #include "semaphore.h"
  52. #include "link.h"
  53. #include "lsn.h"
  54. #include "latch.h"
  55. #include "bf.h"
  56. #include "volume.h"
  57. #include "trans.h"
  58. #include "trans_intfuncs.h"
  59. #include "trans_extfuncs.h"
  60. #include "thread_globals.h"
  61. #include "trans_globals.h"
  62. #include "distr.h"
  63.  
  64.  
  65.  TRANSREC
  66. *allocTrans ()
  67.  
  68. {
  69.  
  70.     TRANSREC    *transRec;
  71.  
  72.  
  73.     TRACE(TR_TRANS, TR_LEVEL_1);
  74.  
  75.     /*
  76.      *    Get a transaction record
  77.      */
  78.     if ((transRec = (TRANSREC *) poolDeq( &TransRecPool )) == NULL)    {
  79.  
  80.         SM_ERROR(TYPE_WARNING, esmNOFREETRANSREC);
  81.         return(NULL);
  82.     }
  83.  
  84.     /*
  85.      *    Initialize the transaction record
  86.      */
  87.     transRec->transState     = T_ACTIVE;
  88.     transRec->firstLSN.offset = NULL_LSN;
  89.     transRec->firstLSN.wrapCount = 0;
  90.     transRec->lastLSN         = NULL_LSN;
  91.     transRec->rememberedLSN     = NULL_LSN;
  92.     transRec->threadCount     = 1;
  93.     transRec->lockWeight     = 0;
  94.     transRec->visitCount     = 0;
  95.     transRec->logRecordCount = 0;
  96.     transRec->nextUndoLSN     = NULL_LSN;
  97.     transRec->masterThread     = NULL;
  98.     transRec->masterLink     = NULL;
  99.     transRec->loggingOn          = TRUE;
  100.     transRec->logSpace          = 0;
  101.     transRec->undoLogSpace     = 0;
  102.     transRec->gtidRec          = NULL;          /* for distr trans */
  103.     transRec->intent          = T_INACTIVE;  /* for distr trans */
  104.     transRec->numServers     = 0;            /* for distr trans */
  105.     transRec->numVotesRecd     = 0;            /* for distr trans */
  106.     transRec->numAcksRecd     = 0;            /* for distr trans */
  107.     transRec->clientCommand     = C_UNKNOWN;    /* for distr trans */
  108.     transRec->coordCommand     = C_UNKNOWN;    /* for distr trans */
  109.     transRec->numLocks         = 0;            /* for distr trans */
  110.     transRec->prepareLSN.offset = NULL_LSN;    /* for distr trans */
  111.     transRec->prepareLSN.wrapCount = 0;     /* for distr trans */
  112.     transRec->prepareAndCommit     = FALSE;    /* for distr trans */
  113.     initializeList(&(transRec->fileDeallocList));
  114.     initializeList(&(transRec->pageDeallocList));
  115.     initializeList(&(transRec->tempFileList));
  116.     initializeList(&(transRec->tempPageList));
  117.     initializeList(&(transRec->pendingBitmapList)); /* for distr trans */
  118.     initializeList(&(transRec->serverList)); /* for distr trans */
  119.  
  120.     /*
  121.      *    hang it on the active list
  122.      */
  123.     listEnq( &ActiveTransList, &(transRec->activeTransList) );
  124.  
  125.     /*
  126.      *    hang it off the current tcb
  127.      */
  128.     listEnq( &(transRec->threadList), &(Active->transList) );
  129.  
  130.     /*
  131.      *    initialize the thread to point to the transaction record
  132.      */
  133.     Active->transRec = (char *) transRec;
  134.     TRPRINT(TR_TRANS, TR_LEVEL_2, ("transRec:%x", transRec));
  135.  
  136.     /*
  137.      *    return a pointer to the transaction record
  138.      */
  139.     return(transRec);
  140.  
  141. }
  142.